<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/9/21 0021
 * Time: 20:37
 */

namespace com;

use think\Exception;
use think\Log;
use think\Session;

class SmsUtils
{

    static function send($mobile,$content,$controller){

        if($controller==null){
            throw new Exception('参数controller请设置为$this');
        }

        $sms_sp =  $controller->mipInfo['sms_sp'];

        $lingkai_corpid =  $controller->mipInfo['lingkai_corpid'];
        $lingkai_pwd =  $controller->mipInfo['lingkai_pwd'];

        if($sms_sp=='lingkai'){
            return SmsUtils::lingkai_send($mobile,$content,$lingkai_corpid,$lingkai_pwd);
        }
        throw new Exception('没有找到可用的短信服务商，目前只能使用凌凯短信');
    }
    /**
     * @param $mobile
     * @param $content
     * @param $corpid
     * @param $pwd
     * @return mixed|null
     * 调用凌凯短信接口发送短信
     */
   static function lingkai_send($mobile,$content,$corpid,$pwd){
       $content2 = urlencode(iconv( "UTF-8", "gb2312//IGNORE" , $content));
       $url="https://sdk2.028lk.com/sdk2/BatchSend2.aspx?CorpID=$corpid&Pwd=$pwd&Mobile=$mobile&Content=$content2&Cell=&SendTime=";

       $res = getData($url);
       return $res;
   }

}